#include "trap.h" 
    .org 0x0         
    .text
    .global _start
_start:
    # 初始化寄存器的值
    addi.w      $a0, $a0, 0x2aa    # a0 = 0x000002aa
    addi.w      $a1, $a1, 0x3cc    # a1 = 0xfffff3cc
    ori         $a2, $a2, 0x4ff    # a2 = 0x000004ff
    pcaddu12i   $a3, 0x12345       # a3 = 0x12345000 + 0x80000000 = 0x91234500
    addi.w      $a4, $a4, 0x5bb    # a4 = 0x5bb
    addi.w      $a5, $a5, 0x600    # a5 = 0x600
    andi        $a6, $a1, 0xfff    # a6 = 0x000003cc
    st.w        $a0, $s4, 0x7ff    # 存储a0 = 0x000002aa 到内存地址0x8ff
    st.b        $a1, $s4, 0x111    # 存储a1 = 0xfffff3cc 到内存地址0x111
    ld.w        $s1, $s4, 0x7ff    # 从0x8ff加载数据到s1，s1 = 0x000002aa
    ld.b        $s2, $s4, 0x111    # 从0x111加载数据到s2，s2 = 0xfffff3cc

    # 执行一些简单的算术操作
    add.w       $a7, $a0, $a1      # a7 = 0x000002aa + 0xfffff3cc = 0x00000575
    xor         $s3, $a0, $a2      # s3 = 0x000002aa ^ 0x000004ff = 0x00000655
    or          $s4, $s1, $a3      # s4 = 0x000002aa | 0x91234500 = 0x912345aa
    sltu        $t1, $a6, $a1      # t1 = 0x0，比较a6和a1的大小，a6 < a1
   

    # 执行一些位运算
    xor         $s5, $a0, $a3      # s5 = 0x000002aa ^ 0x91234500 = 0x912347aa
    or          $s6, $a1, $a2      # s6 = 0xfffff3cc | 0x000004ff = 0xfffff7ff

    # 执行加载指令
    lu12i.w     $t0, 0x22222       # t0 = 0x22222000
    add.w       $a3, $a0, $a1       # a3 = 0x80400064
    xor         $s7, $a0, $a2      # s7 = 0x000002aa ^ 0x000004ff = 0x00000655

    # 存储操作
    st.w        $a0, $s4, 0x333    # 存储a0 = 0x000002aa 到0x999
    st.b        $a1, $s4, 0x222    # 存储a1 = 0xfffff3cc 到0x222

    # 结束程序，触发一个异常或中断，模拟结束
    HIT_GOOD_TRAP                    # 自定义的一个触发trap的操作，可以替换成系统提供的陷阱指令
